<template>
  <div class="home">
    <el-button type="success" @click="add()">测试一下</el-button>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  data() {
    return {
      info: [1],
    }
  },
  name: 'Home',
  components: {},
  methods: {
    add() {
      this.Axios.get('/try/ajax/json_demo.json?id=123', {
        params: {
          id: 999,
          name: '888',
        },
      })
        .then((response) => {
          console.log(response)
        })
        .catch(function (error) {
          // 请求失败处理
          console.log(error)
        })

      //axios post

      this.Axios.post('/try/ajax/demo_axios_post.php')
        .then((response) => {
          console.log(response)
        })
        .catch(function (error) {
          // 请求失败处理
          console.log(error)
        })
      // this.Axios.all([this.fun1(), this.fun2(), this.fun3()]).then(
      //   this.Axios.spread(function (acct, perms, ceshi) {
      //     // 两个请求现在都执行完成
      //     console.log(acct)
      //     console.log(perms)
      //     console.log(ceshi)
      //   })
      // )
    },
    fun3() {
      // return setTimeout(() => {
      //   this.Axios.get('/try/ajax/json_demo.json?id=123')
      // }, 3000)
      return this.Axios.get('/try/ajax/json_demo.json?id=123')
    },
    fun1() {
      // return setTimeout(() => {
      //   this.Axios.get('/try/ajax/json_demo.json?id=123')
      // }, 3000)
      return this.Axios.get('/try/ajax/json_demo.json?id=123')
    },
    fun2() {
      return this.Axios.post('/try/ajax/demo_axios_post.php')
    },
  },
}
</script>
